オブジェクトの親(SIObject
から派生するオブジェクト)を、次のように戻します。
シーン ルートの Parent プロパティを呼び出す場合は(Model)、Parent プロパティ自身を戻します。
その他のX3DObjectの Parent プロパティを呼び出す場合は、その
X3DObject の親が戻されます。
Propertyの Parent
プロパティを呼び出す場合は、そのプロパティを所有する X3DObject が戻されます。
Parameterの Parent
プロパティを呼び出す場合は、そのパラメータが直接含まれるProjectItemが戻されます。ProjectItem.Parametersコレクションには子オブジェクト内のパラメータが含まれていることがよくあります。たとえば、X3DObject
には、実際にKinematicsやその他のネストされているプロパティからきたパラメータが含まれていることがあります。このため、Parent
プロパティはパラメータがどこから来たものかを判断する上で、非常に役立ちます。この概念は、以下の例に表されています。
ジオメトリコンポーネント(Point、Geometry、またはSegment)の Parent プロパティを呼び出す場合は、親Facetが戻されます。
SubComponentの Parent
プロパティを呼び出した場合は、親ジオメトリが戻されます。これは、SubComponent
オブジェクトにはジオメトリコンポーネントへの参照が含まれているためです(サブコンポーネントの親である実際の X3DObject
を取得するには、SubComponent.Parent3DObjectを使用します)。
Primitive上の Parent
プロパティを呼び出す場合は、親Clusterが戻されます。
Operator上の Parent
プロパティを呼び出す場合は、オペレータの最初のOutputPortのターゲットが戻されます。
モデルの下のActionSourceの Parent
プロパティを呼び出すと、Modelが戻されます。SimulationEnvironmentキャッシュ上の
Parent プロパティを呼び出すと、SimulationEnvironmentが戻されます。この変更は
v5.0 によるものです。以前のリリースでは、Mixerオブジェクトが戻されていました。
- 親を持たないApplicationオブジェクト(オブジェクトなど)の
Parent プロパティを呼び出すと、オブジェクトが親として戻されます。
Commandのような単純なオブジェクトは、親としてXSIApplicationを戻します。
ヒント:共用されているMaterialのように、オブジェクトの中には実際に複数の親を持つものもあります。そして中には、同じオブジェクトがシーンエキスプローラ内やグラフ内の複数の場所に現れるという場合もあります。このような場合は、ProjectItem.Ownersプロパティを使用してすべての「親」にアクセスできます。
注:現在、SIObject
のすべてのネストされた子を見つけるための、同様なプロパティは存在しません。代わりに、これらの子は、タイプ(X3DObject.Children、ProjectItem.Parameters、ParticleCloudPrimitive.Particles、X3DObject.Primitivesなど)に応じてさまざまなコレクションで使用できます。EnumElementsコマンドは、タイプに関らず、すべての子を見つける方法の
1 つです。
'
' This example displays the name of the object's parent
'
set oObj = ActiveProject.ActiveScene.Root.AddGeometry("Sphere", "NurbsSurface")
Application.LogMessage oObj.Parent.Name
|
set oObject = ActiveSceneroot.AddGeometry("Cube","MeshSurface","MyCube")
set oCluster = oObject.ActivePrimitive.Geometry.AddCluster(siVertexCluster,"MyCluster",Array(3,4,5))
set oSubComponent = oCluster.CreateSubComponent
set oClusterGeometry = oSubComponent.Parent
set oObjectGeometry = oObject.Parent
Application.LogMessage "The parent of " & oSubComponent & " is " & oClusterGeometry
Application.LogMessage "The parent of the " & oObject & " is " & oObjectGeometry
' OUTPUT OF ABOVE SCRIPT IS:
'INFO : "The parent of MyCube.pnt[3-5] is polymsh"
'INFO : "The parent of the MyCube is Scene_Root"
|
#
# This Python example demonstrates how the Parent property can
# be used to travel from a child SIObject to its parent
#
# Expected results: each line in the scripted history should print "True"
# Prepare a simple scene and collect some object model
# references to objects inside it
Application.NewScene( "", 0 )
oSceneRoot = Application.ActiveSceneRoot
oNull = oSceneRoot.AddNull()
oNullLocalKine = oNull.Kinematics.Local
oNestedCone = oNull.AddGeometry( "Cone","MeshSurface","NestedCone")
oNestedConeGeom = oNestedCone.ActivePrimitive.Geometry
# Parent of Scene Root is itself
Application.LogMessage( oSceneRoot.Parent.IsEqualTo( oSceneRoot ) )
# Parent of Null is the Scene Root
Application.LogMessage( oNull.Parent.IsEqualTo( oSceneRoot ) )
# Parent of nested cone is the Null
Application.LogMessage( oNestedCone.Parent.IsEqualTo( oNull ) )
# Parent of a property is the direct owner
Application.LogMessage( oNull.Kinematics.Parent.IsEqualTo( oNull ) )
# Parent of a parameter
Application.LogMessage( oNullLocalKine.Parameters("posx").Parent.FullName
== oNullLocalKine.FullName )
# This same parameter also appears directly under the Null,
# but the Parent property tells the truth about where it comes from
Application.LogMessage( oNull.Parameters("posx").Parent.FullName
== oNullLocalKine.FullName )
# Use Parent to travel all the way from a Point to its X3DObject
Application.LogMessage( oNestedConeGeom.Points(0).Parent.Parent.Parent.IsEqualTo( oNestedCone ) )
# Command object just returns the XSIApplication as its parent
Application.LogMessage( Application.Commands(0).Parent.IsEqualTo( Application ) )
|